﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FileMonitor.Service.Prototype;
using System.IO;
using FileMonitor.Service.ProcessMonitor.Manager;
namespace FileMonitor.Service.Tracking
{
    public class ProcessMonitorTracking:ITracking
    {
        public void StartProcess(FileMonitorBase process)
        { }
        
        public void StopProcess(FileMonitorBase process)
        { }
        
        public void InsertNewFile(FileMonitorBase process, string filePath)
        {
            ProcessStateMonitorManager.Current.AddNewFile(filePath, process);
        }

        public void CompleteFile(FileMonitorBase process, string filePath)
        {
            string fileName = Path.GetFileName(filePath);
            string backupPath = Path.Combine(process.BaseConfiguration.BackUpPath, fileName);
            ProcessStateMonitorManager.Current.CompleteFile(filePath, backupPath, process);
        }

        public void PreocessErrorFile(FileMonitorBase process, string filePath, Exception ex)
        {
            string errorPath = filePath + ".Error";
            ProcessStateMonitorManager.Current.LogErrorFile(filePath, errorPath,process,ex.Message);
        }

        public string TrackingName
        {
            get
            {
                return "ProcessMonitorTracking";
            }
        }

        public int OrderNo 
        {
            get
            {
                return 2;
            }
        }
    }
}
